package com.health.mapp.impl;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import com.health.db.model.UserLIST;
import com.health.db.service.user.IUserLISTService;
import com.health.mapp.bean.Header;
import com.health.mapp.bean.LogoutReq;
import com.health.mapp.bean.LogoutResp;
import com.health.mapp.utils.DateUtils;
import com.health.mapp.utils.Response;
import com.health.mapp.utils.ResultCode;
/**
 * 会员退出登录
 * @author bobo
 *
 */
public class LogoutImpl implements ActionInterface {

	private static Logger logger = Logger.getLogger(LogoutImpl.class);
	private IUserLISTService userLISTService  ;
	@Override
	public Response execute(Header header, Object reqBean) throws Exception {
	 
		
		LogoutReq req = (LogoutReq) reqBean;
		LogoutResp _resp = new LogoutResp();
		
		
		if (StringUtils.isNotBlank(req.getUserId())) {
			//登录信息
			UserLIST userLISTForUpdate = new UserLIST();
			userLISTForUpdate.setUserid(Long.valueOf(req.getUserId()));
			userLISTForUpdate.setLogoutDatetime(DateUtils.now());
			userLISTForUpdate.setUserNo(req.getMdn());
			userLISTService.updateLoginInfo(userLISTForUpdate);
	 
		}else{
			_resp.setErrorCode(ResultCode.OPERATION_LAKE_PARAMETER_USERID);
			_resp.setErrorMsg(ResultCode.OPERATION_LAKE_PARAMETER_USERID_NOTE);
			return _resp;
		}
		
		return _resp;
	}
	/**
	 * @return the userLISTService
	 */
	public IUserLISTService getUserLISTService() {
		return userLISTService;
	}
	/**
	 * @param userLISTService the userLISTService to set
	 */
	public void setUserLISTService(IUserLISTService userLISTService) {
		this.userLISTService = userLISTService;
	}

	
}
